﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="msBsc.WebUi.AddNewOrders"
    CodeBehind="AddNewOrders.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>添加订单信息</title>

    <link href="/themes/wStyle1/css/Seller/sReleaseForum.css" rel="stylesheet" />
    <style>
        .selArea, #selOrderSource {
            width: 140px;
            height: 30px;
            line-height: 30px;
            margin-right: 10px;
            font-family: 微软雅黑;
            font-size: 16px;
            color: #808080;
        }

        input[type=text] {
            width: 290px;
            height: 26px;
        }

        #btnSubmit {
            margin-left: 200px;
            margin-top: 20px;
            cursor: pointer;
            width: 140px;
            background-color: #3c93e8;
            color: #fff;
            line-height: 30px;
            border: 0;
            font-size: 16px;
            font-family: 微软雅黑;
        }

            #btnSubmit:hover {
                opacity: 0.8;
            }

        .notice {
            font-size: 14px;
            font-family: 微软雅黑;
            color: #f00;
            padding-left: 10px;
        }

        .wf_all {
            width: 1000px;
            margin: 40px auto;
        }

        #txtINITIAL_DT_S, #txtINITIAL_DT_E {
            width: 136px;
        }
    </style>
    <script type="text/javascript">
        $(window).load(function () {
            $('#txtINITIAL_DT_S').date_input('%Y-%m-%d %H:%M');
            $('#txtINITIAL_DT_E').date_input('%Y-%m-%d %H:%M');
        });
    </script>
</head>
<body>
    <div class="wf_all">
        <input type="hidden" id="hidVehicleId" value="" />
        <div class="main-container">
            <div class="main-Info">
                <div class="main-horizontal">
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">车辆名称</span>
                        <div class="controls">
                            <input type="text" id="txtVehicleName" disabled="disabled" value="" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">车牌号</span>
                        <div class="controls">
                            <input type="text" id="txtVehicleCode" disabled="disabled" value="" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">卖家姓名</span>
                        <div class="controls">
                            <input type="text" id="txtSolderName" disabled="disabled" value="" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">卖家电话</span>
                        <div class="controls">
                            <input type="text" id="txtSolderPhone" disabled="disabled" value="" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">代理姓名</span>
                        <div class="controls">
                            <input type="text" id="txtAgentName" disabled="disabled" value="" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">买家姓名<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" disabled="disabled" id="txtBuyerName" class="custInput" value="" placeholder="请输入买家姓名" /><span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">买家性别<span class="required">*</span></span>
                        <div class="controls">
                            <input type="radio" id="radFeMale" name="radGender" class="custInput" checked="checked" value="F" /><label for="radFeMale">男</label>
                            <input type="radio" id="radMale" name="radGender" class="custInput" value="F" /><label for="radMale">女</label>
                            <span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">买家电话<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="txtBuyerPhone" class="custInput" disabled="disabled" value="" placeholder="请输入买家电话" /><span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">服务时间<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" disabled="disabled" class="custInput" id="txtINITIAL_DT_S" value="" />
                            - 
                            <input type="text" disabled="disabled" class="custInput" id="txtINITIAL_DT_E" value="" />
                            <span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">定金金额<span class="required">*</span></span>
                        <div class="controls">
                            ￥<input type="text" id="txtOrderCount" class="custInput" disabled="disabled" style="width: 250px;" value="" placeholder="请输入定金金额" />
                            元
                            <span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">定单总额<span class="required">*</span></span>
                        <div class="controls">
                            ￥<input type="text" id="txtOrderTotal" class="custInput" disabled="disabled" style="width: 250px;" value="" placeholder="请输入定单总额" />
                            元
                            <span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">订单来源<span class="required">*</span></span>
                        <div class="controls">
                            <input type="radio" class="custInput" checked="checked" id="radTaobao" name="radOrderSource" value="1" /><label for="radTaobao">淘宝</label>
                            <input type="radio" class="custInput" id="radQunar" name="radOrderSource" value="2" /><label for="radQunar">去哪儿</label>
                            <input type="radio" class="custInput" id="radJD" name="radOrderSource" value="3" /><label for="radJD">京东</label>
                            <span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">来源编号<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="txtSourceCode" class="custInput" disabled="disabled" value="" placeholder="请输入定单来源提供的订单编号" />
                            <span class="notice"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span" style="width: 200px">订单备注</span>
                        <div class="controls">
                            <textarea cols="80" rows="4" id="txtAOrderRemark" style="height: 80px;" placeholder="请输入订单备注信息"></textarea>
                        </div>
                    </div>
                    <div class="r_row">
                        <div class="controls">
                            <input type="button" disabled="disabled" class="custInput" id="btnSubmit" value="确认提交" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="/jqPlugin/js/jBase.js"></script>
    <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>
    <script type="text/javascript">
        $(function () {
            //获取代理信息
            var vehicleId = GetQueryStr("vehicleid");

            //判断代理信息是否为空
            if (!IsNull(vehicleId)) {
                $("#hidVehicleId").val(vehicleId);
                $("input[class=custInput],select[class=custInput]").removeAttr("disabled");
                GetDefaultShowInfo(vehicleId);
            }
        })

        function GetDefaultShowInfo(vehicleId) {
            var opart = new jsonRow();
            opart.AddCell("VehicleId", vehicleId);
            opart.AddCell("ACTION", "GetDefaultInfo");
            ajaxComm(opart);
        }

        function ShowDefaultInfo(IsHasVehicle, vehicleNme, vehicleCode, solderNme, solderPhone, agentNme) {
            if (IsHasVehicle == "N") {
                $("#btnSubmit").attr("disabled", "disabled");
                alert("该车辆不存在，不能进行添加订单信息");
                return;
            }

            $("#txtVehicleName").val(vehicleNme);
            $("#txtVehicleCode").val(vehicleCode);
            $("#txtSolderName").val(solderNme);
            $("#txtSolderPhone").val(solderPhone);
            $("#txtAgentName").val(agentNme);
        }

        //提交填写好的信息
        $("#btnSubmit").click(function () {
            var buyerName = $("#txtBuyerName").val();
            if (IsNull(buyerName)) {
                ShowErrMsg("txtBuyerName", "买家姓名不能为空");
                return;
            }

            var telPhone = $("#txtBuyerPhone").val();
            if (IsNull(telPhone)) {
                ShowErrMsg("txtBuyerPhone", "买家联系电话不能为空");
                return;
            }

            var startTime = $("#txtINITIAL_DT_S").val();
            var stopTime = $("#txtINITIAL_DT_E").val();
            if (IsNull(startTime)) {
                ShowErrMsg("txtINITIAL_DT_S", "服务开始时间不能为空");
                return;
            }
            if (IsNull(stopTime)) {
                ShowErrMsg("txtINITIAL_DT_E", "服务结束时间不能为空");
                return;
            }

            var orderVal = $("#txtOrderCount").val();
            if (IsNull(orderVal)) {
                ShowErrMsg("txtOrderCount", "定金金额不能为空");
                return;
            }
            if (isNaN(orderVal)
                || orderVal <= 0) {
                ShowErrMsg("txtOrderCount", "定金金额必须为大于零的数字");
                return;
            }

            var totalVal = $("#txtOrderTotal").val();
            if (IsNull(totalVal)) {
                ShowErrMsg("txtOrderTotal", "定单总额不能为空");
                return;
            }
            if (isNaN(totalVal)
                || totalVal - orderVal <= 0) {
                ShowErrMsg("txtOrderTotal", "定单总额必须为大于定金金额");
                return;
            }

            var sourceCode = $("#txtSourceCode").val();
            if (IsNull(sourceCode)) {
                ShowErrMsg("txtSourceCode", "订单来源编号不能为空");
                return;
            }

            var orderRemark = $("#txtAOrderRemark").val();

            var opart = new jsonRow();
            opart.AddCell("buyerName", buyerName);
            opart.AddCell("buyerGender", $("input[name=radGender]:checked").val());
            opart.AddCell("telPhone", telPhone);
            opart.AddCell("startTime", startTime);
            opart.AddCell("stopTime", stopTime);
            opart.AddCell("orderVal", orderVal);
            opart.AddCell("totalVal", totalVal);
            opart.AddCell("sourceType", $("input[name=radOrderSource]:checked").val());
            opart.AddCell("sourceCode", sourceCode);
            opart.AddCell("orderRemark", orderRemark);
            opart.AddCell("VehicleId", $("#hidVehicleId").val());
            opart.AddCell("ACTION", "AddOrderInfo");

            var showConfirmStr = "确认为地接客[" + $("#txtSolderName").val() + "]的车辆【" + $("#txtVehicleCode").val() + "】添加订单？\r\n定金金额为:￥" + orderVal + "元 订单总金额为:￥" + totalVal + "元";
            if (confirm(showConfirmStr)) {
                $(this).attr("disabled", "disabled");
                ajaxComm(opart, null, function () {
                    $("#btnSubmit").removeAttr("disabled");
                });
            }

        })

        function AddSuccess() {
            if (confirm("是否继续为地接客[" + $("#txtSolderName").val() + "]的车辆【" + $("#txtVehicleCode").val() + "】添加订单？")) {
                window.location.href = "/ShpMana/AddNewOrders.aspx?vehicleId=" + $("#hidVehicleId").val();
            }
        }

        //显示错误提示信息
        /*
        * targetId:发生错误的标签的Id
        * msgStr:错误提示信息
        */
        function ShowErrMsg(targetId, msgStr) {
            $("#" + targetId).css("border-color", "#f00").siblings(".notice").text(msgStr);

            $("#" + targetId).blur(function () {
                $(this).css("border", "2px inset").siblings(".notice").text("");
            })
        }
    </script>
</body>
</html>
